package com.ikaros.utils;

import com.ikaros.emnus.LoginEnum;
import lombok.Getter;

/**
 * Created by Ikaros on 2017/9/27.
 */
@Getter
public class ResltUtil<T> {
    private Integer code;
    private String msg;
    private T data;

    public ResltUtil() {
    }

    public ResltUtil(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResltUtil(Integer code) {
        this.code = code;
    }

    public ResltUtil(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResltUtil(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResltUtil success(){
        return new ResltUtil<T>(LoginEnum.SUCCESS.getCode());
    }

    public static <T> ResltUtil success(String msg){
        return new ResltUtil<T>(LoginEnum.SUCCESS.getCode(),msg);
    }

    public static <T> ResltUtil success(T data){
        return new ResltUtil<T>(LoginEnum.SUCCESS.getCode(),data);
    }

    public static <T> ResltUtil success(String msg, T data){
        return new ResltUtil<T>(LoginEnum.SUCCESS.getCode(),msg,data);
    }

    public static <T> ResltUtil error(){
        return new ResltUtil<T>(LoginEnum.ERROR.getCode(),LoginEnum.ERROR.getMsg());
    }

    public static <T> ResltUtil error(String msg){
        return new ResltUtil<T>(LoginEnum.ERROR.getCode(),msg);
    }

    public static <T> ResltUtil error(Integer code,String msg){
        return new ResltUtil<T>(code,msg);
    }
}
